package com.jhh.pay.center.log;

import com.alibaba.fastjson.JSON;
import com.jhh.pay.center.search.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author tangxd
 * @Description: TODO
 * @date 2017/12/4
 */
@Slf4j
@Service
public class OrderLogSearcher extends AbstractElasticSearcher<OrderLog> {

    @Autowired
    @Qualifier("log_index_router")
    private IndexRouter<String> router;

    @Override
    protected String getIdxName() {
        return "jhh-pay-logs";
    }

    @Override
    protected String getIdxAlias() {
        return "jhh-pay-logs-v1";
    }

    @Override
    protected String getIdxTypeName() {
        return "order-log";
    }

    @Override
    protected IndexRouter getRouter() {
        return router;
    }

    @Override
    protected DocTransformer<OrderLog, String> mappingTransformer() {
        return JSON::toJSONString;
    }

    @Override
    protected DocTransformer<String, OrderLog> sourceTransformer() {
        return data -> JSON.parseObject(data, OrderLog.class);
    }

    @Override
    public Map<String, Object> initSetting() {
        return null;
    }

    @Override
    public void putMapping() {

    }

    @Override
    public <Q extends AbstractQuery> PagedList<OrderLog> search(Q query) {
        return null;
    }
}
